/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package eu.fastl.dragster.model;

import java.io.UnsupportedEncodingException;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * Immutable Model Class for recording one execution
 * @author Ernst Fastl
 */
public class ExecutionRecord {

    private final long executionTime;
    private final Object uniqueId;
    private byte[] type;
    private byte[] detail;

    ExecutionRecord(long executionTime, Object uniqueId, String type, String detail) {
        this.executionTime = executionTime;
        this.uniqueId = uniqueId;
        try {
            this.type = type.getBytes("UTF-8");
            this.detail = detail.getBytes("UTF-8");
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }
    }

    public long getExecutionTime() {
        return this.executionTime;
    }

    public Object getUniqueId() {
        return this.uniqueId;
    }

    public String getType() {
        return new String(type);
    }

    public String getDetail() {
        return new String(detail);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
